<template>
  <view class="auditStatus">
    <view class="successStatus public" v-if="status==0">
      <view class="successImg">
        <image style="width: 366rpx; height: 220rpx;" src="../../static/image/cancelSuccess.png" mode=""></image>
      </view>
      <view class="successTxt">核销成功</view>
      <view class="successNum txt">￥ {{price}}</view>
      <view class="btnBottom">
        <view class="cancelBtnDiv">
          <button class="cancelBtn" @click="goOBtn">继续核销</button>
        </view>
        <view class="affirmBtnDiv">
          <button class="affirmBtn" @click="affirmAudit">完成</button>
        </view>
      </view>
    </view>
    <view class="breakDownStatus public" v-else>
      <view class="successImg">
        <image style="width: 366rpx; height: 220rpx;" src="../../static/image/cancelLoser.png" mode=""></image>
      </view>
      <view class="successTxt">核销失败</view>
      <view class="breakDownNum">非本店爆品或核销码过期</view>
      <view class="breakDownBtn">
        <view class="breakDown">
          <button class="affirmBtn" @click="goOBtn">继续核销</button>
        </view>
      </view>
    </view>
  </view>
</template>

<script>
import { decideEnv, setWxConfigSync, isIOS } from '@/unit/common.js';
  export default {
    data () {
      return {
        price:'',
        status:0,
      }
    },
    onLoad (option) {
      this.status = option.status;
      this.price = option.price;
    },
    methods: {
      goOBtn () { // 继续核销
        let that = this;
        if (decideEnv() && decideEnv() == 'wx' && !isIOS()) {
          setWxConfigSync().then(jswx => {
            jswx.scanQRCode({
              needResult: 1, // 默认为0，扫描结果由微信处理，1则直接返回扫描结果，
              scanType: ['qrCode', 'barCode'], // 可以指定扫二维码还是一维码，默认二者都有
              success: function (res) {
                let result = res.resultStr; // 当needResult 为 1 时，扫码返回的结果
                // #ifdef H5
                window.open(result, '_self');
                // #endif
              }
            });
          });
        } else if (decideEnv() && decideEnv() == 'wx' && isIOS()) {
          that.$jswx.ready(function () {
            that.$jswx.scanQRCode({
              needResult: 1, // 默认为0，扫描结果由微信处理，1则直接返回扫描结果，
              scanType: ['qrCode', 'barCode'], // 可以指定扫二维码还是一维码，默认二者都有
              success: function (res) {
                let result = res.resultStr; // 当needResult 为 1 时，扫码返回的结果
                // #ifdef H5
                window.open(result, '_self');
                // #endif
              }
            });
          });
        }
      },
      affirmAudit () { // 点击完成
        uni.switchTab({
          url: '/pages/index/index'
        }); 
      }
    }
  }
</script>

<style lang="scss" scoped>
  .auditStatus {
    .public {
      padding-top: 222rpx;
      text-align: center;
      .successTxt {
        margin-top: 61rpx;
        font-size:32rpx;
        font-weight:bold;
        color:rgba(67,67,67,1);
      }
      .successNum {
        margin-top: 70rpx;
        font-size:56rpx;
        font-weight:bold;
        color:rgba(67,67,67,1);
      }
      .breakDownNum {
        font-size:28rpx;
        font-weight:bold;
        color:rgba(153,153,153,1);
        margin-top: 35rpx;
      }
    }
    .successStatus {
    }
    .btnBottom {
      position: absolute;
      bottom: 0;
      width: 100%;
      height: 100rpx;
      padding: 0 30rpx;
      border-top: 1px solid rgba(225,225,225,1);
      display: flex;
      align-content: space-between;
      line-height: 100rpx;
      .cancelBtnDiv {
        margin-top: 14rpx;
        .cancelBtn {
          width:259rpx;
          height:70rpx;
          font-size: 30rpx;
          background:rgba(246,218,153,1);
          border-radius:10rpx;
        }
      }
      .affirmBtnDiv {
        margin-top: 10rpx;
        margin-left: 30rpx;
        .affirmBtn {
          width:407rpx;
          height:70rpx;
          font-size: 30rpx;
          border-radius:10rpx;
          background:rgba(67,67,67,1);
          color: #F6DA99;
        }
      }
    }
    .breakDownBtn {
      position: absolute;
      bottom: 0;
      width: 100%;
      height: 100rpx;
      border-top: 1px solid rgba(225,225,225,1);
      .breakDown {
        margin-top: 10rpx;
        margin: 10rpx 30rpx 0 30rpx;
        .affirmBtn {
          height:70rpx;
          width: 100%;
          font-size: 30rpx;
          border-radius:10rpx;
          background:#F6DA99;
          color: #434343;
        }
      }
    }
  }
</style>
